package com.lifang.imsoa.facadeimpl;

import com.lifang.imsoa.util.RedisKey;
import com.lifang.xmemcached.RedisClientAdapterImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2015/12/3.
 */
@Slf4j
@Service
public class ClearRedis {
    @Autowired
    private RedisClientAdapterImpl redisClientAdapter;
    //缓存时间
    @Value("${I_cacheTime}")
    private int cacheTime;

    public void clearRedisByHxId(String hxId) {
        if(hxId!=null) {
            redisClientAdapter.delete(RedisKey.hxUserStatus.key(hxId));
            log.info("清除缓存成功,hxId={}", hxId);
        }
    }

    public void clearRedisListByHxIds(List<String> hxIds) {
        if(hxIds!=null) {
            for (String hxId : hxIds) {
                if (hxId != null)
                    redisClientAdapter.delete(hxId);
            }
        }
        log.info("清除缓存列表,hxIds={}",hxIds);
    }
}
